import { Image } from 'antd';
import { NumText } from '@/pages/OrderModule/common/components/CommonText/components/NumText';
import CommonInput from '@/pages/OrderModule/common/components/CommonInput';
import CommonInputNumber from '@/pages/OrderModule/common/components/CommonInputNumber';
import Typography from '@/pages/OrderModule/common/components/Typography';
import Style from './index.module.less';

export function useGoodsColumns({ handleNumChange }) {
  const goodsColumns = [
    {
      title: '序号',
      dataIndex: 'field1',
      render(value, record, index) {
        return index + 1
      },
    },
    // {
    //   title: '图片',
    //   dataIndex: 'sysGoodsImage',
    //   render(value, record) {
    //     return <Image className={Style.goods_image} width={55} src={sysGoodsImage} />;
    //   },
    // },
    {
      title: '商品',
      dataIndex: 'sysGoodsName',
      render(value, record) {
        return <Typography as="s1">{value}</Typography>;
      },
    },
    {
      title: '商品编码',
      dataIndex: 'sysSkuCode',
      render(value, record) {
        return <Typography as="s1">{value}</Typography>;
      },
    },
    {
      title: '款式编码',
      dataIndex: 'sysSpuCode',
      render(value, record) {
        return <Typography as="s1">{value}</Typography>;
      },
    },
    {
      title: '当前数量',
      dataIndex: 'goodsNum',
      render(value, record) {
        // return <NumText as="s1" num={value} point={0} />;
        return value;
      },
    },
    {
      title: '拆出数量',
      dataIndex: 'splitNum',
      render(value, { goodsNum }, index) {
        return <CommonInputNumber placeholder="请输数量" max={goodsNum-1} value={value} onBlur={e => handleNumChange(e, index)}></CommonInputNumber>;
      },
    },
  ];

  return {
    goodsColumns,
  };
}
